class Student implements Comparable<Student> {
    public String name;
    public int age;


    public Student(String name, int age) {
        this.name = name;
        this.age = age;
    }

    @Override
    public int compareTo(Student o) {
        if(this.age>o.age){
          return 1;
        }else if(this.age<o.age){
           return -1;
       }else {
            return 0;
       }

        //return this.name.compareTo(o.name);
    }

}
public class Test {

    public static void main(String[] args) {
        Student student1=new Student("zhangsan",14);
        Student student2=new Student("lisi",20);
        System.out.println(student1.compareTo(student2));
        //System.out.println(student1.name.compareTo(student2.name));
    }

}
